{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Get the mne-python sample data path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os.path as op\n",
    "from mne.datasets import sample\n",
    "data_path = op.join(sample.data_path(), 'MEG', 'sample')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Call the MMVT MEG pre-processing to create the inverse solution and the source estimate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from src.preproc import meg\n",
    "args = meg.read_cmd_args(dict(\n",
    "    subject='sample', task='audvis', inverse_method='MNE',\n",
    "    function='calc_inverse_operator, calc_stc',\n",
    "    evo_fname=op.join(data_path, 'sample_audvis-ave.fif'),\n",
    "    fwd_fname=op.join(data_path, 'sample_audvis-meg-eeg-oct-6-fwd.fif'),\n",
    "    noise_cov_fname=op.join(data_path, 'sample_audvis-cov.fif'),\n",
    "    inv_loose=0, pick_ori=None))\n",
    "meg.call_main(args)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Run MMVT and plot the source estimate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from src.mmvt_addon.scripts import run_mmvt\n",
    "mmvt = run_mmvt.run(subject='sample')\n",
    "stc_fname = meg.get_stc_fname(args).format(hemi='lh')\n",
    "t = meg.time_to_index(0.08)\n",
    "mmvt.meg.plot_stc(stc_fname, t=t, threshold=1.5, save_image=True)"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
